package com.xiashitech.agent.instrumentation.context;

public class XSCallDepth {
    private int depth = 0;

    private int judgeBottom = 0;

    XSCallDepth() {
    }

    public static XSCallDepth forClass(Class<?> cls) {
        return XSCallDepthThreadLocalMap.getCallDepth(cls);
    }

    public int getAndIncrement() {
        judgeBottom = this.depth++;
        return judgeBottom;
    }

    public int decrementAndGet() {
        return --this.depth;
    }

    public int getJudgeBottom() {
        return judgeBottom;
    }

    public void freshJudgeBottom() {
        this.judgeBottom = 0;
    }

    public int getDepth() {
        return depth;
    }
}
